package com.air.ota.vo;

import com.air.ota.util.HexStringUtil;
import com.air.ota.util.PBOCUtil;
import com.air.ota.util.PkgUtil;

public class UTKModifyPwdUplinkVO extends UTKBaseUplinkPgkVO {
	
	protected byte[] cardAppSequence;
	protected byte[] oldPwdEncrypt;
	protected byte[] newPwdEncrypt;
	//cardRandom和mac1暂时不用
	//protected byte[] cardRandom;
	//protected byte[] mac1;
	protected byte[] pkgSequence;
	
	protected String oldPwdDecrypt;
	protected String newPwdDecrypt;
	
	public UTKModifyPwdUplinkVO(byte[] cardSequence){
		super();
		this.cardSequence = cardSequence;
		
		cardAppSequence = new byte[8];
		oldPwdEncrypt = new byte[8];
		newPwdEncrypt = new byte[8];
		//cardRandom = new byte[4];
		//mac1 = new byte[4];
		pkgSequence = new byte[4];
		
	}
	
	public void parse(byte[] pkg){
		super.parse(pkg);
		super.decryptCmdData();
		
		System.arraycopy(cmdData, 0, cardAppSequence, 0, 8);
		System.arraycopy(cmdData, 8, oldPwdEncrypt, 0, 8);
		System.arraycopy(cmdData, 16, newPwdEncrypt, 0, 8);
		//System.arraycopy(cmdData, 24, cardRandom, 0, 4);
		//System.arraycopy(cmdData, 28, mac1, 0, 4);
		System.arraycopy(cmdData, 24, pkgSequence, 0, 4);
		
		
		PBOCUtil pboc = new PBOCUtil();
		oldPwdDecrypt = HexStringUtil.bytesToHexString(pboc.TripleDes(this.UTKSessionKey, oldPwdEncrypt, 0));
		newPwdDecrypt = HexStringUtil.bytesToHexString(pboc.TripleDes(this.UTKSessionKey, newPwdEncrypt, 0));
		
		System.out.println("old password decrypt="+oldPwdDecrypt);
		System.out.println("new password decrypt="+newPwdDecrypt);
		
		PkgUtil.setCurrentPkgSequence(pkgSequence);
	}

	public byte[] getCardAppSequence() {
		return cardAppSequence;
	}

	public byte[] getOldPwdEncrypt() {
		return oldPwdEncrypt;
	}

	public byte[] getNewPwdEncrypt() {
		return newPwdEncrypt;
	}

	/*public byte[] getCardRandom() {
		return cardRandom;
	}

	public byte[] getMac1() {
		return mac1;
	}*/

	public byte[] getPkgSequence() {
		return pkgSequence;
	}

	public String getOldPwdDecrypt() {
		return oldPwdDecrypt;
	}

	public String getNewPwdDecrypt() {
		return newPwdDecrypt;
	}
	
	
}
